package com.example.student.mapper;

import com.example.student.pojo.Stu;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface StuMapper {

    @Select("select * from students where student_id = #{id}")
    Stu getByID(Integer id);

    @Delete("delete from students where student_id = #{id}")
    void deleteById(Integer id);

    @Select("select * from students")
    List<Stu> list();

    @Update("update students set name = #{name},gender=#{gender},birth =#{birth},update_time = #{updateTime} where student_id = #{studentId}")
    void update(Stu stu);

    @Insert("insert into students(student_id,name,gender,birth,dept_id,create_time,update_time) " +
            "values(#{studentId},#{name},#{gender},#{birth},#{deptId},#{createTime},#{updateTime})")
    void insert(Stu stu);

    @Select("select count(*) from students")
    public long count();

   @Select("select * from students order by student_id  limit #{start},#{pageSize}")
    List<Stu> page(Integer start,Integer pageSize);

    List<Stu> pages(Integer start,Integer pageSize, Integer studentId,String name,Short gender);

    long counts(Integer studentId, String name, Short gender);

    @Select("select count(*) from students where student_id = #{studentId}")
    int findById(Integer studentId);

    @Select("select count(*) from students where dept_id = #{deptId}")
    long classCounts(Integer deptId);

    @Select("select * from students where dept_id = #{deptId} order by student_id limit #{start},#{pageSize}")
    List<Stu> classPages(Integer start, Integer pageSize, Integer deptId);

    @Select(("select max(student_id) from students"))
    int findMax();

    void deleteByIds(List<Integer> ids);
}